package com.example.lin.controller;

import com.example.lin.common.R;
import com.example.lin.entity.dto.LoginDto;
import com.example.lin.entity.vo.LoginUser;
import com.example.lin.service.LoginService;
import com.example.lin.service.impl.UserDetailsServiceImpl;
import jakarta.annotation.Resource;
import jakarta.servlet.ServletException;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

/**
 * @author Administrator
 */
@RestController
@RequestMapping
public class LoginController {

    @Resource
    private LoginService loginService;

    @PostMapping("/login")
    public R login(@RequestBody LoginDto loginDto) throws ServletException, IOException {
        LoginUser login = loginService.login(loginDto);
        return R.ok(login);
    }
}
